{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item" >

                        <div class="layui-input-inline">
                            <input type="text"  name="create_start_time" onfocus="wk.lay_date(this);" class="layui-input layer-date search" placeholder="下单开始日期"/>
                        </div>

                        <div class="layui-input-inline">
                            <input type="text"  name="create_end_time" onfocus="wk.lay_date(this);"  class="layui-input layer-date search" placeholder="下单结束日期"/>
                        </div>

                        <div class="layui-col-md6 layui-input-inline">
                            <select name="order_status" lay-search="">
                                <option  value="">不限状态</option>
                                <option  value="1">待付款</option>
                                <option  value="2">待发货</option>
                                <option  value="3">待收货</option>
                                <option  value="4">待评价</option>
                                <option  value="9">已评价</option>
                                <option  value="5">售后中</option>
                                <option  value="6">已退款</option>
                                <option  value="7">拒绝退款</option>
                                <option  value="8">已关闭</option>
                            </select>
                        </div>

                        <div class="layui-col-md6 layui-input-inline">
                            <select name="order_aftersale_status" lay-search="">
                                <option  value="">不限完成状态</option>
                                <option  value="1">未完成</option>
                                <option  value="2">已完成</option>
                            </select>
                        </div>

                        <div class="layui-input-inline">
                            <select name="goods_cate" lay-search="">
                                <option  value="">不限类目</option>
                                {foreach name="cate" item="v" key="k"}
                                <option  value="{$v['gt_id']}">{$v['gt_name']}</option>
                                {/foreach}
                            </select>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 8px">
                            <select name="order_type" lay-search="">
                                <option  value="">不限类型</option>
                                <option  value="1">普通商品订单</option>
                                <option  value="2">拍卖商品订单</option>
                                <option  value="3">秒杀商品订单</option>
                                <option  value="4">约稿订单</option>
                                <option  value="5">拍卖押金订单</option>
                            </select>
                        </div>

                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 8px">
                            <input type="text" id="goods_name" class="layui-input search" name="goods_name" placeholder="商品名称/约稿标题"/>
                        </div>

                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 8px">
                            <input type="text" id="order_number" class="layui-input search" name="order_number" placeholder="订单号"/>
                        </div>

                        <div class="layui-input-inline"  style="margin-top: 8px">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>
                <!--操作框开始-->

                <!--操作框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="testReload"></table>

                    <!--图片模板-->
                    <script type="text/html" id="imgTpl">
                        <img src="{{d.goods_thumb}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"/>
                    </script>

                    <!--状态显示模板-->
                    <script type="text/html" id="statBar">
                        {{# if(d.order_status == 1){ }}
                        待付款
                        {{# } }}
                        {{# if(d.order_status == 2){ }}
                        待发货
                        {{# } }}
                        {{# if(d.order_status == 3){ }}
                        待收货
                        {{# } }}
                        {{# if(d.order_status == 4){ }}
                        待评价
                        {{# } }}
                        {{# if(d.order_status == 5){ }}
                        售后中
                        {{# } }}
                        {{# if(d.order_status == 6){ }}
                        已退款
                        {{# } }}
                        {{# if(d.order_status == 7){ }}
                        拒绝退款
                        {{# } }}
                        {{# if(d.order_status == 8){ }}
                        已关闭
                        {{# } }}
                        {{# if(d.order_status == 9){ }}
                        已评价
                        {{# } }}
                    </script>

                    <script type="text/html" id="afterStatBar">
                        {{# if(d.order_aftersale_status == 1){ }}
                        未完成
                        {{# } }}
                        {{# if(d.order_aftersale_status == 2){ }}
                        已完成
                        {{# } }}
                    </script>

                    <script type="text/html" id="payType">
                        {{# if(d.order_pay_type == 1){ }}
                        微信
                        {{# } }}
                        {{# if(d.order_pay_type == 2){ }}
                        支付宝
                        {{# } }}
                        {{# if(d.order_pay_type == 3){ }}
                        银联
                        {{# } }}
                        {{# if(d.order_pay_type == 4){ }}
                        visa
                        {{# } }}
                        {{# if(d.order_pay_type == 5){ }}
                        PayPal
                        {{# } }}
                    </script>

                    <script type="text/html" id="orderType">
                        {{# if(d.order_type == 1){ }}
                        普通商品订单
                        {{# } }}
                        {{# if(d.order_type == 2){ }}
                        拍卖商品订单
                        {{# } }}
                        {{# if(d.order_type == 3){ }}
                        秒杀商品订单
                        {{# } }}
                        {{# if(d.order_type == 4){ }}
                        约稿订单
                        {{# } }}
                        {{# if(d.order_type == 5){ }}
                        拍卖押金订单
                        {{# } }}
                    </script>

                    <!--操作模板-->
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.layer_show('详情','{:url('orderDetail')}?order_id={{d.order_id}}')" class="btn btn-warning btn-xs m-r-xs" title="详情"><i class="fa fa-search">详情</i></a>
                        {{# if(d.order_status == 5 || d.order_status == 7) { }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.order_id}}','{:url('orderReturn')}', '确定退款吗？')" class="btn btn-danger btn-xs m-r-xs" title="退款"><i class="fa fa-share-square-o">退款</i></a>
                        {{# } }}
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Order/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
//                {type: 'checkbox', fixed: 'left',}
//                {type:'numbers', width: 60, title: '序号'}
                  {field: 'order_number', width: 180, title: '订单编号', align: 'center'}
                , {field: 'goods_name', width: '', title: '商品名称', align: 'center'}
                , {field: 'yue_title', width: '', title: '约稿标题', align: 'center'}
                , {field: 'goods_thumb', width: 80, title: '缩略图', align: 'center', templet: '#imgTpl'}
                , {field: 'order_num', width: 90, title: '购买数量', align: 'center'}
                , {field: 'order_status', width: 90, title: '订单状态', align: 'center', toolbar: '#statBar'}
                , {field: 'order_aftersale_status', width: 120, title: '订单完成状态', align: 'center', toolbar: '#afterStatBar'}
                , {field: 'order_pay_price', width: 100, title: '实付金额', align: 'center'}
                , {field: 'spec_name', width: 90, title: '规格', align: 'center'}
                , {field: 'spec_can', width: 90, title: '参数', align: 'center'}
                , {field: 'order_pay_type', width: 90, title: '支付方式', align: 'center', toolbar: '#payType'}
                , {field: 'order_type', width: 120, title: '订单类型', align: 'center', toolbar: '#orderType'}
                , {field: 'gt_name', width: 90, title: '商品类目', align: 'center'}
                , {field: 'sail_username', width: 120, title: '卖家昵称', align: 'center'}
                , {field: 'order_sail_user_id', width: 80, title: '卖家ID', align: 'center'}
                , {field: 'sail_userphone', width: 140, title: '卖家手机号', align: 'center'}
                , {field: 'buy_username', width: 120, title: '买家昵称', align: 'center'}
                , {field: 'order_buy_user_id', width: 80, title: '买家ID', align: 'center'}
                , {field: 'buy_userphone', width: 120, title: '买家手机号', align: 'center'}
                , {field: 'order_create_time', width: 160, title: '下单时间', align: 'center'}
                , {fixed: 'right', width: 170, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.img-circle').viewer({
                    url: 'data-original',
                });
            }
        });

        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['order_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>